﻿using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YmatouSeller.Notice.Domain.Interface;
using YmatouSeller.Notice.Repository.Interface;
using YmatouSeller.NoticeAPI.Model.Entity;
using YmatouSeller.NoticeAPI.Model.Enums;

namespace YmatouSeller.Notice.Domain.Implement
{
    public class SystemNoticeService : ISystemNoticeService
    {
        [Dependency]
        public ISystemNoticeDALService SystemNoticeDALService { get; set; }

        #region 消息通知管理
        /// <summary>
        /// 获取国家信息
        /// </summary>
        /// <returns></returns>
        public List<CountryInfo> GetAllCountry(string continent, int countryID, int selectType)
        {
            return SystemNoticeDALService.GetAllCountry(continent, countryID, selectType);
        }

        /// <summary>
        /// 删除通知附件
        /// </summary>
        /// <param name="detailModle"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool DeleteNoticeAttachment(List<long> noticeOptionIds, string noticeId)
        {
            return SystemNoticeDALService.DeleteNoticeAttachment(noticeOptionIds, noticeId);
        }

        /// <summary>
        /// 保存通知消息
        /// </summary>
        /// <param name="detailModle"></param>
        /// <returns></returns>
        public bool SaveSystemNotice(SystemNoticeDetail detailModle)
        {
            return SystemNoticeDALService.SaveSystemNotice(detailModle);
        }

        /// <summary>
        /// 获取通知消息详情
        /// </summary>
        /// <param name="noticeId"></param>
        /// <returns></returns>
        public SystemNoticeDetail GetSystemNoticeItem(string noticeId)
        {
            return SystemNoticeDALService.GetSystemNoticeItem(noticeId);
        }

        /// <summary>
        /// 获取通知消息附件
        /// </summary>
        /// <param name="noticeId"></param>
        /// <returns></returns>
        public List<SystemNoticeAttachment> GetSystemNoticeAttachmentList(List<string> noticeIds)
        {
            return SystemNoticeDALService.GetSystemNoticeAttachmentList(noticeIds);
        }

        /// <summary>
        /// 获取通知消息通知对象
        /// </summary>
        /// <param name="noticeId"></param>
        /// <returns></returns>
        public List<SystemNoticeTarget> GetSystemNoticeTargetList(List<string> noticeIds)
        {
            return SystemNoticeDALService.GetSystemNoticeTargetList(noticeIds);
        }

        /// <summary>
        /// 获取通知消息列表
        /// </summary>
        /// <param name="noticeTitle"></param>
        /// <param name="noticeType"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public List<SystemNotice> GetSystemNoticeList(string noticeTitle, NoticeTypeEnum noticeType, DateTime? beginTime, DateTime? endTime, int pageIndex, int pageSize, out int totalCount)
        {
            return SystemNoticeDALService.GetSystemNoticeList(noticeTitle, noticeType, beginTime, endTime, pageIndex, pageSize, out totalCount);
        }

        #endregion

        /// <summary>
        /// 获取未读数
        /// </summary>
        /// <param name="state"></param>
        /// <param name="sellerid"></param>
        public int GetUnReadNoticeCount(string continent, int sellerid)
        {
            return SystemNoticeDALService.GetUnReadNoticeCount(continent, sellerid);
        }

        /// <summary>
        /// 获取跑马灯
        /// </summary>
        /// <param name="state"></param>
        /// <param name="sellerid"></param>
        /// <returns></returns>
        public List<SystemNotice> GetMoveNoticeList(string continent, int sellerid)
        {
            return SystemNoticeDALService.GetMoveNoticeList(continent, sellerid);
        }

        /// <summary>
        /// 获取全部通知list
        /// </summary>
        /// <param name="state"></param>
        /// <param name="sellerid"></param>
        /// <param name="noticeType"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public List<SystemNotice> GetSellerAllNoticeList(string continent, int sellerid, int noticeType, int total)
        {
            return SystemNoticeDALService.GetSellerAllNoticeList(continent, sellerid, noticeType, total);
        }

        /// <summary>
        /// 阅读通知保存
        /// </summary>
        /// <param name="sellerid"></param>
        /// <param name="noticeid"></param>
        /// <returns></returns>
        public bool SubmitReadNotice(int sellerid, string noticeid, string resource)
        {
            return SystemNoticeDALService.SubmitReadNotice(sellerid, noticeid, resource);
        }

        public List<SystemNoticeDetail> GetSystemNoticeDetailList(int sellerid, string continent, NoticeTypeEnum noticeType,
            DateTime? beginTime, DateTime? endTime, int pageIndex, int pageSize, out int totalCount)
        {
            return SystemNoticeDALService.GetSystemNoticeDetailList(sellerid, continent, noticeType, beginTime, endTime, pageIndex, pageSize, out totalCount);
        }

        public int GetNoticeTypeUnReadCount(int sellerid, string continent, int noticeType)
        {
            return SystemNoticeDALService.GetNoticeTypeUnReadCount(sellerid, continent, noticeType);
        }
    }
}
